drop table usercc
drop table appuser;
commit;

--For appuser table

create table appuser(
	id number,
	firstName varchar2(20),
	lastName varchar2(20),
	userName varchar2(20) not null,
	password varchar2(40),
	constraint appuser_pk primary key (id),
	constraint app_username_uk unique (userName)
)

create sequence appuser_id_seq start with 1 increment by 1;

create or replace trigger appuser_insert
before insert on appuser
for each row
begin
  select appuser_id_seq.nextval into :new.id from dual;
end;
/

select * from appuser

INSERT INTO appuser 
(firstName, lastName, userName, password)
VALUES 
('sat', 'yal', 'syagh', 'saibaba')

commit;

-- for usercc table

create table usercc(
	id number,
	userName varchar2(20)not null,
	ccnumber varchar2(40)not null,
	ccexpdate varchar2(40)not null,
  ccalias  varchar2(40)not null,
	constraint usercc_pk primary key (id),
	constraint usercc_username_fk FOREIGN KEY (userName) REFERENCES appuser (userName)
)


create sequence usercc_seq start with 1 increment by 1;

drop sequence usercc_seq

create or replace trigger usercc_insert
before insert on usercc
for each row
begin
    select usercc_seq.nextval into :new.id from dual;
end;
/

INSERT INTO usercc
(userName, ccnumber, ccexpdate, ccalias)
VALUES 
('syagh', 'xxxxxxxxxxxx7564', '10/20', 'fg3444gh55')

commit;





create table appuser(
	id number,
	firstName varchar2(20),
	lastName varchar2(20),
	userName varchar2(20) not null,
	password varchar2(40),
	constraint appuser_pk primary key (id),
	constraint app_username_uk unique (userName)
)

drop table appuser cascade constraints;
commit

INSERT INTO appuser 
(firstName, lastName, userName, password)
VALUES 
('sat', 'yal', 'syagh', 'saibaba')

select * from usercc

select distinct usercarden0_.userName as userName1_, usercarden0_.ccexpdate as ccexpdate1_, usercarden0_.ccnumber as ccnumber1_ from usercc usercarden0_ where usercarden0_.userName='skondoju'

create table usercc(
	id number,
	userName varchar2(20)not null,
	ccnumber number,
	ccexpdate number,
	constraint usercc_pk primary key (id),
	constraint usercc_username_fk FOREIGN KEY (userName) REFERENCES appuser (userName)
)

delete appuser
select * from appuser
select * from usercc
drop table appuser;
commit;

insert into  appuser values(appuser_id_seq.nextval, firstname(sat), lastname(yal), username(syal), password(saibaba143));

create sequence appuser_id_seq start with 1 increment by 1;
drop sequence appuser_id_seq

remove trigger appuser_insert

delete appuser
commit



======SNIP======
DELIMITER /
create or replace trigger appuser_insert
before insert on appuser
for each row
begin
  select appuser_id_seq into :new.id from dual;
end;
/
DELIMITER ;
======SNAP======

DELIMITER /
create or replace trigger appuser_insert
before insert on appuser
for each row
begin
    select appuser_id_seq.nextval into :new.id from dual;
end;
/
DELIMITER ;
drop trigger appuser_insert
commit